package org.example.demos.web;

import org.junit.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class SecondProvider {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/send")
    public void send() {
        String queueName = "test1";
        String message ="hello spring amqp";
        rabbitTemplate.convertAndSend(queueName,message);

    }
    @GetMapping("/send1")
    public void send1() {
        String exchangeName = "mirror.fanout";
        String message ="hello spring amqp";
        rabbitTemplate.convertAndSend(exchangeName,"",message);
    }
    @GetMapping("/send2")
    public void send2() {
        String exchangeName = "mirror.topic";
        String message ="hello spring amqp";
        rabbitTemplate.convertAndSend(exchangeName,"japan.news",message);
    }
    @GetMapping("/send3")
    public void send3() {
        String exchangeName = "mirror.fanout2";
        String message ="hello spring amqp";
        rabbitTemplate.convertAndSend(exchangeName,"",message);
    }
    @GetMapping("/send4")
    public void send4() {
        String exchangeName = "mirror.direct";
        String message ="hello spring amqp";
        rabbitTemplate.convertAndSend(exchangeName,"red",message);
    }
    @GetMapping("/send5")
    public void send5() {
        String exchangeName = "mirror.test";
        String message ="hello spring amqp";
        rabbitTemplate.convertAndSend(exchangeName,"test2.news",message);
    }
    @GetMapping("/send6")
    public void send6() {
        String exchangeName = "mirror.test";
        String message ="hello spring amqp";
        Map<String,String> map =new HashMap<>();
        map.put("name","zhangsan");
        map.put("age","18");
        rabbitTemplate.convertAndSend(exchangeName,"q",map);
    }
}
